package com.jhd.fuzhou.util;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.RadioButton;

import java.text.SimpleDateFormat;
import java.util.Date;

public class CertificateUtil {//今入先对比一下，有没有身份证号
    public static void check(EditText editText, RadioButton radioButton1, RadioButton radioButton2, EditText age, Context context){
        String number=editText.getText().toString();
        if(number.length()==18){
            String message=IDCardUtil.IDCardValidate(number);
            if("1".equals(message)){
                if((Integer.valueOf(number.substring(16,17))%2)==0){
                    radioButton2.setChecked(true);
                }else{
                    radioButton1.setChecked(true);
                }
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
                Date date = new Date();
                String year=sdf.format(date);
                age.setText(String.valueOf(Integer.valueOf(year)-Integer.valueOf(number.substring(6,10))));
            }else{
                CustomToast.showText(context,message,3000,0,0).show();
            }
        }
    }
}
